package io.io3;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class PWDemo2 {
    public static void main(String[] args) throws FileNotFoundException {
        //文件流（字节流，低级流）：将字节写入到文件中
        FileOutputStream fos=new FileOutputStream("pw.txt");
        OutputStreamWriter osw=new OutputStreamWriter(fos);
        BufferedWriter bow=new BufferedWriter(osw);
        PrintWriter pw=new PrintWriter(bow,true);

        Scanner scan=new Scanner(System.in);
        System.out.println("请开始输入内容，单独输入exit时退出：");
        while (true){
            String line=scan.nextLine();
            if(line.equals("exit")){
                System.out.println("结束");
                break;
            }else {
                pw.println(line);
                //System.out.println("请继续输入：");
                //pw.flush();
            }
        }
        pw.close();
    }
}
